package org.jsbd.boss.util;

import org.apache.commons.io.output.WriterOutputStream;

import java.io.*;
import java.util.zip.GZIPInputStream;
import java.util.zip.ZipOutputStream;

/**
 * @desc
 * @Date 2018/7/26 14:41
 * @Author xupengcheng [xupengcheng@zhexinit.com]
 */
public class GzipUtil {


    public static byte[] releaseGzipCompression(byte[] bytesArray) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ByteArrayInputStream in = new ByteArrayInputStream(bytesArray);
        try {
            GZIPInputStream ungzip = new GZIPInputStream(in);
            byte[] buffer = new byte[1024];
            int n;
            while ((n = ungzip.read(buffer)) >= 0) {
                out.write(buffer, 0, n);
            }
        } catch (IOException e) {

        }
        return out.toByteArray();
    }




}
